package com.quan.system.service.impl;

import java.util.List;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quan.common.core.MyBaseServiceImpl;
import com.quan.system.entity.SystemSettings;
import com.quan.system.mapper.SystemSettingsMapper;
import com.quan.system.service.SystemSettingsService;

/**
 * <p>
 * 系统-常量设置 服务实现类
 * </p>
 *
 * @author 杨浩泉
 * @since 2019-07-03
 */
@Service
public class SystemSettingsServiceImpl extends MyBaseServiceImpl<SystemSettingsMapper, SystemSettings> implements SystemSettingsService {

	@Cacheable(value = "SystemSettings", key = "#root.methodName")
	@Override
	public SystemSettings loadSettings() {

		QueryWrapper<SystemSettings> queryWrapper = new QueryWrapper<SystemSettings>();
		queryWrapper.last("limit 1");

		List<SystemSettings> list = super.list(queryWrapper);

		if (null != list && !list.isEmpty()) {
			return list.get(0);
		}

		return null;
	}

	@CacheEvict(value = "SystemSettings", allEntries = true)
	@Override
	public boolean saveOrUpdate(SystemSettings entity) {
		return super.saveOrUpdate(entity);
	}

}
